<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery3.2.1-dev.js"></script>
</head>
<script type="text/javascript">
	$(function(){
		loadArea("#province",0);
		$("#province").change(function(){
			clearCity();
			clearTown();
			loadArea("#city",$("#province").val());
		});
		$("#city").change(function(){
			clearTown();
			loadArea("#town",$("#city").val());
		});
		
	});
	function loadArea(itemId,parent){
		$.get("areaSer","parentId="+parent,function(result){
			eval("res="+result);
			for(var i = 0; i < res.length;i ++){
				$(itemId).append("<option value='"+res[i].areaid+"'>"+res[i].areaname+"</option>");
			} 
		});
	}
	function clearTown(){
		$("#town").empty();
		$("#town").append("<option value=''>请选择...</option>");
	}
	function clearCity(){
		$("#city").empty();
		$("#city").append("<option value=''>请选择...</option>");
	}
</script>
<body>
<select id="province">
	<option value="">请选择...</option>
</select>省
<select id="city">
	<option value="">请选择...</option>
</select>市
<select id="town">
	<option value="">请选择...</option>
</select>县
</body>
</html>